<?php

namespace Common\Database;

use Common\Interfaces\IDatabase;

class DBPDO implements IDatabase
{
    protected $conn;
    public function connect($host, $user, $password, $db_name)
    {
        try {
            $conn = new \PDO("mysql:host=$host;dbname=$db_name", $user, $password);
            $conn->query('');
            $this->conn = $conn;
        } catch (\Exception $th) {
            echo "?????<br>";
            var_dump($th->getMessage());
        }
        
    }
    /**
     * Undocumented function
     *
     * @param string $sql
     * @return PDOStatement
     */
    public function query($sql)
    {
        return $this->conn->query($sql);
    }
    public function close()
    {
        unset($this->conn);
    }
}
